module.exports = (app) => {
  const { STRING, INTEGER, DECIMAL, DATE, NOW } = app.Sequelize

  const OrderItem = app.model.define(
    't_order_item',
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '订单项主键'
      },
      order_id: {
        type: INTEGER,
        allowNull: false,
        comment: '订单外键ID'
      },
      num: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '数量'
      },
      goods_id: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '商品ID'
      },
      goods_name: {
        type: STRING,
        allowNull: false,
        defaultValue: 0,
        comment: '商品名称'
      },
      goods_price: {
        type: DECIMAL(8, 2),
        allowNull: false,
        defaultValue: 0,
        comment: '商品价格'
      },
      goods_img: {
        type: STRING,
        allowNull: false,
        defaultValue: 0,
        comment: '商品价格'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '创建时间'
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '更新时间'
      }
    },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false
    }
  )
  return OrderItem
}
